<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>开源应用容器引擎 Docker_01Docker入门 | Oct25-X</title><meta name="keywords" content="Docker"><meta name="author" content="Oct25-X"><meta name="copyright" content="Oct25-X"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Docker 基础一、什么是 DockerDocker 是基于 Go 语言实现的云开源项目。 Docker 的主要目标是“Build, Ship and Run Any App, Anywhere”，也就是通过对应用组件 的封装、分发、部署、运行等生命周期的管理，使用户的 APP（可以是一个 Web 应用或数据库应用等等）及其运行环境能够做到“一次镜像，处处运行”。  Build, Ship an">
<meta property="og:type" content="article">
<meta property="og:title" content="开源应用容器引擎 Docker_01Docker入门">
<meta property="og:url" content="https://oct25-x.atomgit.net/oct25-xxxxx/2023/11/03/35%E5%BC%80%E6%BA%90%E5%BA%94%E7%94%A8%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8EDocker_01Docker%E5%85%A5%E9%97%A8/index.html">
<meta property="og:site_name" content="Oct25-X">
<meta property="og:description" content="Docker 基础一、什么是 DockerDocker 是基于 Go 语言实现的云开源项目。 Docker 的主要目标是“Build, Ship and Run Any App, Anywhere”，也就是通过对应用组件 的封装、分发、部署、运行等生命周期的管理，使用户的 APP（可以是一个 Web 应用或数据库应用等等）及其运行环境能够做到“一次镜像，处处运行”。  Build, Ship an">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://oct25-x.atomgit.net/oct25-xxxxx/img/cover_img/ctt35.png">
<meta property="article:published_time" content="2023-11-03T04:01:37.000Z">
<meta property="article:modified_time" content="2024-02-17T14:22:55.268Z">
<meta property="article:author" content="Oct25-X">
<meta property="article:tag" content="Docker">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://oct25-x.atomgit.net/oct25-xxxxx/img/cover_img/ctt35.png"><link rel="shortcut icon" href="/oct25-xxxxx/img/logo.jpg"><link rel="canonical" href="https://oct25-x.atomgit.net/oct25-xxxxx/2023/11/03/35%E5%BC%80%E6%BA%90%E5%BA%94%E7%94%A8%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8EDocker_01Docker%E5%85%A5%E9%97%A8/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/oct25-xxxxx/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/oct25-xxxxx/',
  algolia: undefined,
  localSearch: {"path":"search.json","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '开源应用容器引擎 Docker_01Docker入门',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2024-02-17 22:22:55'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/rightMenu.css"><meta name="generator" content="Hexo 6.1.0"></head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/oct25-xxxxx/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><div class="data-item"><a href="/oct25-xxxxx/archives/"><div class="headline">文章</div><div class="length-num">52</div></a></div><div class="data-item"><a href="/oct25-xxxxx/tags/"><div class="headline">标签</div><div class="length-num">17</div></a></div><div class="data-item"><a href="/oct25-xxxxx/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/oct25-xxxxx/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/oct25-xxxxx/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/oct25-xxxxx/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/oct25-xxxxx/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/oct25-xxxxx/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/oct25-xxxxx/img/top_img/top_bg9.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/oct25-xxxxx/">Oct25-X</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/oct25-xxxxx/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/oct25-xxxxx/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/oct25-xxxxx/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/oct25-xxxxx/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/oct25-xxxxx/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">开源应用容器引擎 Docker_01Docker入门</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2023-11-03T04:01:37.000Z" title="发表于 2023-11-03 12:01:37">2023-11-03</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-02-17T14:22:55.268Z" title="更新于 2024-02-17 22:22:55">2024-02-17</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/oct25-xxxxx/categories/%E5%AE%B9%E5%99%A8%E5%8C%96/">容器化</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="开源应用容器引擎 Docker_01Docker入门"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Docker-基础"><a href="#Docker-基础" class="headerlink" title="Docker 基础"></a>Docker 基础</h1><h2 id="一、什么是-Docker"><a href="#一、什么是-Docker" class="headerlink" title="一、什么是 Docker"></a>一、什么是 Docker</h2><p>Docker 是基于 Go 语言实现的云开源项目。</p>
<p>Docker 的主要目标是“Build, Ship and Run Any App, Anywhere”，也就是通过对应用组件 的封装、分发、部署、运行等生命周期的管理，使用户的 APP（可以是一个 Web 应用或数据库应用等等）及其运行环境能够做到<strong>“一次镜像，处处运行”</strong>。</p>
<blockquote>
<p>Build, Ship and Run Any App, Anywhere</p>
<p>构建，装载，运行任何 APP，在任何地方</p>
</blockquote>
<p>Docker 就是将应用打包成镜像，通过镜像成为运行在 Docker 容器上面的实例，而 Docker 容器在任何操作系统上都是一致的，这就实现了跨平台、跨服务器。</p>
<p>Docker 解决了运行环境和配置问题的软件容器，方便做持续集成，并有助于整体发布的窗口虚拟化技术。</p>
<h2 id="二、容器和虚拟机比较"><a href="#二、容器和虚拟机比较" class="headerlink" title="二、容器和虚拟机比较"></a>二、容器和虚拟机比较</h2><h3 id="虚拟机"><a href="#虚拟机" class="headerlink" title="虚拟机"></a>虚拟机</h3><p>传统虚拟机技术基于安装在主操作系统上的虚拟管理系统（如：VMWare 和 VirtualBox等），创建虚拟机，在虚拟机上安装从操作系统，在从操作系统中安装部署各种应用。</p>
<p>Windows10 –&gt; VMWare –&gt; CentOS7 –&gt; cpu、内存、网络配置 + 各种软件 –&gt; 虚拟机实例</p>
<p><img src="/oct25-xxxxx/img/docker/docker01.png" alt="虚拟机示例"></p>
<p><strong>虚拟机缺点</strong></p>
<ol>
<li>资源占用多；</li>
<li>冗余步骤多；</li>
<li>启动慢；</li>
</ol>
<h3 id="容器虚拟化技术"><a href="#容器虚拟化技术" class="headerlink" title="容器虚拟化技术"></a>容器虚拟化技术</h3><p>Linux 容器（Linux Containers，缩写为 LXC）是与系统其他部分隔离开的一系列进程，从另一个镜像运行，并由该镜像提供支持进程所需的全部文件。</p>
<p>容器提供的镜像包含了应用的所有依赖项，因而在从开发到测试再到生产的整个过程中，它都是具有可移植性和一致性的。</p>
<p>Linux 容器不是模拟一个完整的操作系统，而是对进行进行隔离。有了容器，就可以将软件运行所需的所有资源打包到一个隔离的容器中。</p>
<p>容器与虚拟机不同，不需要捆绑一整操作系统，只需要软件工作所需的库资源和设置。系统因此而变得高效轻量，并保证部署在任何环境中的软件都能始终如一地运行。</p>
<p><img src="/oct25-xxxxx/img/docker/docker02.png" alt="虚拟化技术示例"></p>
<p>Docker 容器是在操作系统层面上实现虚拟化，直接复用了本地主机的操作系统，而传统虚拟机则是在硬件层面实现虚拟化。与传统的虚拟机相比，DocKer 优势体现为启动速度快、占用体积小。</p>
<h2 id="三、Docker-能干什么"><a href="#三、Docker-能干什么" class="headerlink" title="三、Docker 能干什么"></a>三、Docker 能干什么</h2><p>开发&#x2F;运维（DevOps）</p>
<ul>
<li>一次构建 、随处运行</li>
<li>更快速的应用交付和部署</li>
<li>更便捷的升级和扩容</li>
<li>更简单的系统运维</li>
<li>更高效的计算资源利用</li>
</ul>
<p>应用场景</p>
<p><img src="/oct25-xxxxx/img/docker/docker03.png" alt="docker应用场景"></p>
<p>Docker 借鉴了标准集装箱的概念。标准集装箱将货物运往世界各地，Docker 将这个模型运用到自己的设计中，唯一不同的是：集装箱运输货物，而 Docker 运输软件。</p>
<h2 id="四、Docket-组成"><a href="#四、Docket-组成" class="headerlink" title="四、Docket 组成"></a>四、Docket 组成</h2><h3 id="概念"><a href="#概念" class="headerlink" title="概念"></a>概念</h3><h4 id="镜像（Image）"><a href="#镜像（Image）" class="headerlink" title="镜像（Image）"></a>镜像（Image）</h4><p>Docker 镜像（Image）就是一个只读的模板。镜像可以用来创建 Docker 容器，<strong>一个镜像可以创建很多容器</strong>。</p>
<blockquote>
<p>镜像：可以理解为 Java 中的类（或者类模板）</p>
<p>容器：可以理解为 Java 中 new 出来的类的实例</p>
</blockquote>
<h4 id="容器（Container）"><a href="#容器（Container）" class="headerlink" title="容器（Container）"></a>容器（Container）</h4><ol>
<li>从面向对象角度</li>
</ol>
<p>Docker 利用容器（Container）独立运行的一个或一组应用，应用程序或服务运行在容器里面，容器就类似于一个虚拟化的运行环境，<strong>容器就是用镜像创建的运行实例</strong>。</p>
<p>容器是镜像运行时的实体。</p>
<p>容器为镜像提供了一个标准的和隔离的运行环境，它可以被启动、开始、停止、删除。</p>
<p>每个容器都是相互隔离的、保证安全的平台。</p>
<blockquote>
<p>容器：可以理解为 Java 中 new 出来的类的实例</p>
</blockquote>
<ol start="2">
<li>从镜像容器角度</li>
</ol>
<p><strong>可以把容器看做是一个简单版的 Linux 环境</strong>（包括 root 用户权限、进程空间、用户空间和网络空间等）和运行在其中的应用程序。</p>
<h4 id="仓库（Repository）"><a href="#仓库（Repository）" class="headerlink" title="仓库（Repository）"></a>仓库（Repository）</h4><p>仓库（Repository）是集中存放镜像文件的场所。</p>
<blockquote>
<p>类似于：</p>
<p>Maven 仓库，存放各种 jar 包的地方；</p>
<p>Github 仓库，存放各种 git 项目的地方；</p>
</blockquote>
<p>Docker 公司提供的官方 Repository 被称为 Docker Hub，存放各种镜像模板的地方。</p>
<p>仓库分为公开仓库（Public）和私有仓库（Private）两种形式。</p>
<p>最大的公开仓库是 Docker Hub（<a target="_blank" rel="noopener" href="https://hub.docker.com/%EF%BC%89">https://hub.docker.com/）</a></p>
<p>存放了数量庞大的镜像供用户下载。国内公开仓库包括阿里云、网易云等。</p>
<h3 id="Docker-平台架构图解（入门）"><a href="#Docker-平台架构图解（入门）" class="headerlink" title="Docker 平台架构图解（入门）"></a>Docker 平台架构图解（入门）</h3><p><img src="/oct25-xxxxx/img/docker/docker04.png" alt="docker平台架构"></p>
<h3 id="Docker-工作原理"><a href="#Docker-工作原理" class="headerlink" title="Docker 工作原理"></a>Docker 工作原理</h3><p>Docker 是一个 Client-Server 结构的系统，Docker 守护进程（上图中的 Docker daemon）运行在主机上，然后通过 Socket 连接从客户端访问，守护进程从客户端接收命令并管理运行在主机上的容器。</p>
<h1 id="Docker-安装"><a href="#Docker-安装" class="headerlink" title="Docker 安装"></a>Docker 安装</h1><h2 id="一、Docker-下载"><a href="#一、Docker-下载" class="headerlink" title="一、Docker 下载"></a>一、Docker 下载</h2><p>Docker 官网：<a target="_blank" rel="noopener" href="http://www.docker.com/">http://www.docker.com</a></p>
<p>Docker Hub 官网：<a target="_blank" rel="noopener" href="https://hub.docker.com/">https://hub.docker.com</a></p>
<h2 id="二、Docker-安装"><a href="#二、Docker-安装" class="headerlink" title="二、Docker 安装"></a>二、Docker 安装</h2><ol>
<li>确定系统为 CentOS7 及以上版本</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cat</span> /etc/redhat-release</span><br><span class="line">CentOS Linux release 7.8.2003 (Core)</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>如果已安装，需要先卸载</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">yum remove docker \</span><br><span class="line">    docker-client \</span><br><span class="line">    docker-client-latest \</span><br><span class="line">    docker-common \</span><br><span class="line">    docker-latest \</span><br><span class="line">    docker-latest-logrotate \</span><br><span class="line">    docker-logrotate \</span><br><span class="line">    docker-engine</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>yum 安装相关软件包</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">yum -y install gcc gcc-c++</span><br><span class="line">yum -y install yum-utils</span><br></pre></td></tr></table></figure>

<ol start="4">
<li>设置 stable 镜像仓库为阿里云仓库地址</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">yum-config-manager \</span><br><span class="line">    --add-repo \</span><br><span class="line">    https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo</span><br></pre></td></tr></table></figure>

<p>注：换成阿里云镜像仓库后，速度会有所提升</p>
<ol start="5">
<li>更新 yum 软件包索引</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum makecache fast</span><br></pre></td></tr></table></figure>

<ol start="6">
<li>安装 docker CE</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin</span><br></pre></td></tr></table></figure>

<ol start="7">
<li>启动与停止 docker</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">systemctl start docker</span><br><span class="line">systemctl stop docker</span><br></pre></td></tr></table></figure>

<ol start="8">
<li>开机启动设置</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">systemctl <span class="built_in">enable</span> docker</span><br><span class="line">systemctl <span class="built_in">disable</span> docker</span><br></pre></td></tr></table></figure>

<ol start="9">
<li>查看 docker 版本</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker -v</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Docker version 23.0.4, build f480fb1</span><br></pre></td></tr></table></figure>

<ol start="10">
<li>卸载</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">systemctl stop docker</span><br><span class="line">yum remove docker-ce docker-ce-cli containerd.io docker-compose-plugin</span><br><span class="line"><span class="built_in">rm</span> -rf /var/lib/docker</span><br><span class="line"><span class="built_in">rm</span> -rf /var/lib/containerd</span><br></pre></td></tr></table></figure>


<h2 id="三、hello-world"><a href="#三、hello-world" class="headerlink" title="三、hello-world"></a>三、hello-world</h2><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run hello-world</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">Unable to find image <span class="string">&#x27;hello-world:latest&#x27;</span> locally</span><br><span class="line">latest: Pulling from library/hello-world</span><br><span class="line">2db29710123e: Pull complete </span><br><span class="line">Digest: sha256:4e83453afed1b4fa1a3500525091dbfca6ce1e66903fd4c01ff015dbcb1ba33e</span><br><span class="line">Status: Downloaded newer image <span class="keyword">for</span> hello-world:latest</span><br><span class="line"></span><br><span class="line">Hello from Docker!</span><br><span class="line">This message shows that your installation appears to be working correctly.</span><br><span class="line"></span><br><span class="line">To generate this message, Docker took the following steps:</span><br><span class="line"> 1. The Docker client contacted the Docker daemon.</span><br><span class="line"> 2. The Docker daemon pulled the <span class="string">&quot;hello-world&quot;</span> image from the Docker Hub.</span><br><span class="line">    (amd64)</span><br><span class="line"> 3. The Docker daemon created a new container from that image <span class="built_in">which</span> runs the</span><br><span class="line">    executable that produces the output you are currently reading.</span><br><span class="line"> 4. The Docker daemon streamed that output to the Docker client, <span class="built_in">which</span> sent it</span><br><span class="line">    to your terminal.</span><br><span class="line"></span><br><span class="line">To try something more ambitious, you can run an Ubuntu container with:</span><br><span class="line"> $ docker run -it ubuntu bash</span><br><span class="line"></span><br><span class="line">Share images, automate workflows, and more with a free Docker ID:</span><br><span class="line"> https://hub.docker.com/</span><br><span class="line"></span><br><span class="line">For more examples and ideas, visit:</span><br><span class="line"> https://docs.docker.com/get-started/</span><br></pre></td></tr></table></figure>

<h2 id="四、阿里云镜像加速"><a href="#四、阿里云镜像加速" class="headerlink" title="四、阿里云镜像加速"></a>四、阿里云镜像加速</h2><h3 id="注册阿里云账户"><a href="#注册阿里云账户" class="headerlink" title="注册阿里云账户"></a>注册阿里云账户</h3><p><a target="_blank" rel="noopener" href="https://promotion.aliyun.com/ntms/act/kubernetes.html">https://promotion.aliyun.com/ntms/act/kubernetes.html</a></p>
<h3 id="获得加速器地址连接"><a href="#获得加速器地址连接" class="headerlink" title="获得加速器地址连接"></a>获得加速器地址连接</h3><ol>
<li>进入到控制台</li>
<li>在侧边栏”所有产品与服务”中，找到”容器镜像服务”，然后进入</li>
<li>在左侧找到”镜像工具” -&gt; “镜像加速器”</li>
<li>然后复制”加速器地址”即可</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://***.mirror.aliyuncs.com</span><br></pre></td></tr></table></figure>

<h3 id="配置镜像加速器"><a href="#配置镜像加速器" class="headerlink" title="配置镜像加速器"></a>配置镜像加速器</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">mkdir</span> -p /etc/docker</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">tee</span> /etc/docker/daemon.json &lt;&lt;-<span class="string">&#x27;EOF&#x27;</span></span><br><span class="line">&#123;</span><br><span class="line">  <span class="string">&quot;registry-mirrors&quot;</span>: [<span class="string">&quot;https://***.mirror.aliyuncs.com&quot;</span>]</span><br><span class="line">&#125;</span><br><span class="line">EOF</span><br></pre></td></tr></table></figure>

<p>重启服务</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">systemctl daemon-reload</span><br><span class="line">systemctl restart docker</span><br></pre></td></tr></table></figure>

<p>重新测试 hello-world</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run hello-world</span><br></pre></td></tr></table></figure>



<h1 id="Docker-常用命令"><a href="#Docker-常用命令" class="headerlink" title="Docker 常用命令"></a>Docker 常用命令</h1><h2 id="一、帮助启动类命令"><a href="#一、帮助启动类命令" class="headerlink" title="一、帮助启动类命令"></a>一、帮助启动类命令</h2><h3 id="启动-Docker"><a href="#启动-Docker" class="headerlink" title="启动 Docker"></a>启动 Docker</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl start docker</span><br></pre></td></tr></table></figure>

<h3 id="停止-Docker"><a href="#停止-Docker" class="headerlink" title="停止 Docker"></a>停止 Docker</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl stop docker</span><br></pre></td></tr></table></figure>

<h3 id="重启-Docker"><a href="#重启-Docker" class="headerlink" title="重启 Docker"></a>重启 Docker</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart docker</span><br></pre></td></tr></table></figure>

<h3 id="查看-Docker-状态"><a href="#查看-Docker-状态" class="headerlink" title="查看 Docker 状态"></a>查看 Docker 状态</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl status docker</span><br></pre></td></tr></table></figure>

<h3 id="开机启动-Docker"><a href="#开机启动-Docker" class="headerlink" title="开机启动 Docker"></a>开机启动 Docker</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl <span class="built_in">enable</span> docker</span><br></pre></td></tr></table></figure>

<h3 id="查看-Docker-概要信息"><a href="#查看-Docker-概要信息" class="headerlink" title="查看 Docker 概要信息"></a>查看 Docker 概要信息</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker info</span><br></pre></td></tr></table></figure>

<h3 id="查看-Docker-帮助文档"><a href="#查看-Docker-帮助文档" class="headerlink" title="查看 Docker 帮助文档"></a>查看 Docker 帮助文档</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker --<span class="built_in">help</span></span><br></pre></td></tr></table></figure>

<h3 id="查看-Docker-具体命令帮助文档"><a href="#查看-Docker-具体命令帮助文档" class="headerlink" title="查看 Docker 具体命令帮助文档"></a>查看 Docker 具体命令帮助文档</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker 具体命令 --<span class="built_in">help</span></span><br></pre></td></tr></table></figure>

<h2 id="二、镜像命令"><a href="#二、镜像命令" class="headerlink" title="二、镜像命令"></a>二、镜像命令</h2><h3 id="列出本地主机上的镜像"><a href="#列出本地主机上的镜像" class="headerlink" title="列出本地主机上的镜像"></a>列出本地主机上的镜像</h3><p>语法</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">docker images [OPTIONS]</span><br><span class="line"></span><br><span class="line"><span class="comment">#OPTIONS 说明</span></span><br><span class="line">-a：列出本地所有的镜像，包含历史映像层</span><br><span class="line">-q：只显示镜像<span class="built_in">id</span></span><br></pre></td></tr></table></figure>

<p>示例</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">docker images</span><br><span class="line"></span><br><span class="line">REPOSITORY    TAG       IMAGE ID       CREATED         SIZE</span><br><span class="line">hello-world   latest    feb5d9fea6a5   13 months ago   13.3kB</span><br></pre></td></tr></table></figure>

<p>各参数说明</p>
<ul>
<li>REPOSITORY：表示镜像的仓库源</li>
<li>TAG：镜像的标签版本号</li>
<li>IMAGE ID：镜像id</li>
<li>CREATED：镜像创建时间</li>
<li>SIZE：镜像大小</li>
</ul>
<h3 id="查询镜像"><a href="#查询镜像" class="headerlink" title="查询镜像"></a>查询镜像</h3><p>语法</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">docker search [OPTIONS] 镜像名</span><br><span class="line"></span><br><span class="line"><span class="comment">#OPTIONS 说明</span></span><br><span class="line">--<span class="built_in">limit</span>：只列出N个镜像，默认25个</span><br></pre></td></tr></table></figure>

<p>示例</p>
<p>查询hello-world镜像</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker search hello-world</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">NAME 			DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED</span><br><span class="line">hello-world		Hello World! (an example of minimal Dockeriz…   1887      [OK] </span><br></pre></td></tr></table></figure>

<p>查询redis镜像</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker search --<span class="built_in">limit</span> 5 redis</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">NAME            		 DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED</span><br><span class="line">redis                    Redis is an open <span class="built_in">source</span> key-value store that…   12036     [OK]       </span><br><span class="line">redislabs/redisearch     Redis With the RedisSearch module pre-loaded…   56                   </span><br><span class="line">redislabs/redisinsight   RedisInsight - The GUI <span class="keyword">for</span> Redis                 87                   </span><br><span class="line">redislabs/rebloom        A probablistic datatypes module <span class="keyword">for</span> Redis        22                   [OK]</span><br><span class="line">redislabs/redis          Clustered in-memory database engine compatib…   36 </span><br></pre></td></tr></table></figure>

<p>各参数说明</p>
<ul>
<li>NAME：镜像名</li>
<li>DESCRIPTION：描述</li>
<li>STARS：点选数</li>
<li>OFFICIAL：是否是官方认证</li>
<li>AUTOMATED：是否是自动构建的</li>
</ul>
<h3 id="拉取镜像"><a href="#拉取镜像" class="headerlink" title="拉取镜像"></a>拉取镜像</h3><p>语法</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"> docker pull 镜像名[:TAG]</span><br><span class="line"></span><br><span class="line"><span class="comment">#y说明</span></span><br><span class="line"><span class="comment">#1、[:TAG]为可选参数</span></span><br><span class="line"><span class="comment">#2、没有 TAG 就是最新版本镜像，等价于 docker pull 镜像名:latest</span></span><br></pre></td></tr></table></figure>

<p>示例</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull ubuntu</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">Using default tag: latest</span><br><span class="line">latest: Pulling from library/ubuntu</span><br><span class="line">2ab09b027e7f: Pull complete </span><br><span class="line">Digest: sha256:67211c14fa74f070d27cc59d69a7fa9aeff8e28ea118ef3babc295a0428a6d21</span><br><span class="line">Status: Downloaded newer image <span class="keyword">for</span> ubuntu:latest</span><br><span class="line">docker.io/library/ubuntu:latest</span><br></pre></td></tr></table></figure>

<p>查询本地镜像</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker search</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">REPOSITORY    TAG       IMAGE ID       CREATED         SIZE</span><br><span class="line">ubuntu        latest    08d22c0ceb15   7 weeks ago     77.8MB</span><br><span class="line">hello-world   latest    feb5d9fea6a5   19 months ago   13.3kB</span><br></pre></td></tr></table></figure>

<h3 id="查看镜像-x2F-容器-x2F-数据卷所占空间"><a href="#查看镜像-x2F-容器-x2F-数据卷所占空间" class="headerlink" title="查看镜像&#x2F;容器&#x2F;数据卷所占空间"></a>查看镜像&#x2F;容器&#x2F;数据卷所占空间</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker system <span class="built_in">df</span></span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE</span><br><span class="line">Images          2         1         77.82MB   77.81MB (99%)</span><br><span class="line">Containers      1         0         0B        0B</span><br><span class="line">Local Volumes   0         0         0B        0B</span><br><span class="line">Build Cache     0         0         0B        0B</span><br></pre></td></tr></table></figure>

<h3 id="删除镜像"><a href="#删除镜像" class="headerlink" title="删除镜像"></a>删除镜像</h3><p>语法</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">docker rmi 镜像名/镜像<span class="built_in">id</span></span><br><span class="line">docker rmi -f 镜像名1/镜像id1:TAG 镜像名2/镜像id2:TAG </span><br><span class="line"></span><br><span class="line"><span class="comment"># OPTION 说明</span></span><br><span class="line">-f：强制删除</span><br></pre></td></tr></table></figure>


<p>示例</p>
<p>查看当前镜像</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker images</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">REPOSITORY    TAG       IMAGE ID       CREATED         SIZE</span><br><span class="line">ubuntu        latest    08d22c0ceb15   7 weeks ago     77.8MB</span><br><span class="line">hello-world   latest    feb5d9fea6a5   19 months ago   13.3kB</span><br></pre></td></tr></table></figure>

<p>删除hello-world</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker rmi feb5d9fea6a5</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">Error response from daemon: conflict: unable to delete feb5d9fea6a5 (must be forced) - image is being used by stopped container bacff7cf7bbd</span><br></pre></td></tr></table></figure>

<p>强制删除</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker rmi -f feb5d9fea6a5</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">Untagged: hello-world:latest</span><br><span class="line">Untagged: hello-world@sha256:4e83453afed1b4fa1a3500525091dbfca6ce1e66903fd4c01ff015dbcb1ba33e</span><br><span class="line">Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412</span><br></pre></td></tr></table></figure>

<h3 id="思考：什么是虚悬镜像？"><a href="#思考：什么是虚悬镜像？" class="headerlink" title="思考：什么是虚悬镜像？"></a>思考：什么是虚悬镜像？</h3><ol>
<li>是什么：仓库名、标签都是 &lt;none&gt; 的镜像，俗称虚悬镜像 dangling image</li>
<li>长什么样</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">REPOSITORY    TAG       IMAGE ID       CREATED         SIZE</span><br><span class="line">&lt;none&gt;   &lt;none&gt;    feb5d9fea6a5   13 months ago   13.3kB</span><br></pre></td></tr></table></figure>

<h2 id="三、容器命令"><a href="#三、容器命令" class="headerlink" title="三、容器命令"></a>三、容器命令</h2><p>有镜像才能创建容器（以ubuntu演示）</p>
<h3 id="新建，并启动容器"><a href="#新建，并启动容器" class="headerlink" title="新建，并启动容器"></a><code>新建，并启动容器</code></h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run [OPTIONS] IMAGE[COMMAND][ARG...]</span><br></pre></td></tr></table></figure>

<p>各参数说明：</p>
<ul>
<li>OPTIONS：可选参数</li>
<li>IMAGE：镜像</li>
<li>COMMAND：命令</li>
</ul>
<h4 id="OPTIONS-说明"><a href="#OPTIONS-说明" class="headerlink" title="OPTIONS 说明"></a>OPTIONS 说明</h4><p>–name&#x3D;”容器新名字”：为一个容器指定一个名称</p>
<p><code>-d：后台运行容器，并返回容器id，也即启动守护式容器（后台运行）</code></p>
<p><strong>-i：以交互模式运行容器，通常与 -t 同时使用</strong></p>
<p><strong>-t：为容器重新分配一个伪输入终端，通常与 -i 同时使用，也即启动交互式容器（前台有伪终端，等待交互）</strong></p>
<p>-P：随机端口号（注：大写P）</p>
<p>-p：指定端口映射（注：小写p）</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>-p hostPort:containerPort</td>
<td>端口映射 -p 8080:6379</td>
</tr>
<tr>
<td>-p ip:hostPort:containerPort</td>
<td>配置监听地址 -p 10.0.0.100:88080:80</td>
</tr>
<tr>
<td>-p ip::containerPort</td>
<td>随机分配端口 -p 10.0.0.100::80</td>
</tr>
<tr>
<td>-p hostPort:containerPort:udp</td>
<td>指定协议 -p 8080:80:tcp</td>
</tr>
<tr>
<td>-p 81:80 -p 433:433</td>
<td>指定多个映射</td>
</tr>
</tbody></table>
<h4 id="启动交互式容器（前台命令行）"><a href="#启动交互式容器（前台命令行）" class="headerlink" title="启动交互式容器（前台命令行）"></a>启动交互式容器（前台命令行）</h4><p>使用镜像 ubuntu:latest，以交互模式启动一个容器，在容器内执行 &#x2F;bin&#x2F;bash 命令</p>
<p><img src="/oct25-xxxxx/img/docker/docker06.png" alt="使用docker交互式运行ubuntu，并返回shell终端"></p>
<h3 id="列出当前所有正在运行的容器"><a href="#列出当前所有正在运行的容器" class="headerlink" title="列出当前所有正在运行的容器"></a>列出当前所有正在运行的容器</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker ps [OPTIONS]</span><br></pre></td></tr></table></figure>

<h4 id="OPTIONs-说明"><a href="#OPTIONs-说明" class="headerlink" title="OPTIONs 说明"></a>OPTIONs 说明</h4><p>-a：列出当前所有正在运行的容器 + 历史上运行过的</p>
<p>-l：显示最近创建的容器</p>
<p>-n：显示最近n个创建的容器</p>
<p><strong>-q：静默模式，只显示容器编号</strong></p>
<p><strong>示例</strong></p>
<p><img src="D:\其他\笔记资料\BigData19_开源应用服务引擎Docker\img\docker07.png" alt="查看当前运行docker容器"></p>
<h3 id="退出容器"><a href="#退出容器" class="headerlink" title="退出容器"></a>退出容器</h3><p><strong>exit：</strong>使用 docker run 进入容器，通过 exit 退出，<code>容器停止</code></p>
<p><strong>Ctrl + p + q：</strong>使用 docker run 进入容器，通过 Ctrl + p + q 退出，<code>容器不停止</code></p>
<h3 id="启动已停止运行的容器"><a href="#启动已停止运行的容器" class="headerlink" title="启动已停止运行的容器"></a>启动已停止运行的容器</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker start 容器<span class="built_in">id</span>或容器名</span><br></pre></td></tr></table></figure>

<h3 id="重启容器"><a href="#重启容器" class="headerlink" title="重启容器"></a>重启容器</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker restart 容器<span class="built_in">id</span>或容器名</span><br></pre></td></tr></table></figure>

<h3 id="停止容器"><a href="#停止容器" class="headerlink" title="停止容器"></a>停止容器</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker stop 容器<span class="built_in">id</span>或容器名</span><br></pre></td></tr></table></figure>

<h3 id="强制停止容器"><a href="#强制停止容器" class="headerlink" title="强制停止容器"></a>强制停止容器</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker <span class="built_in">kill</span> 容器<span class="built_in">id</span>或容器名</span><br></pre></td></tr></table></figure>

<h3 id="删除已停止的容器"><a href="#删除已停止的容器" class="headerlink" title="删除已停止的容器"></a>删除已停止的容器</h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker <span class="built_in">rm</span> 容器<span class="built_in">id</span>或容器名</span><br></pre></td></tr></table></figure>

<h3 id="启动守护式容器（后台服务）"><a href="#启动守护式容器（后台服务）" class="headerlink" title="启动守护式容器（后台服务）"></a><code>启动守护式容器（后台服务）</code></h3><p>大部分场景下，我们希望 Docker 的服务是在后台运行的，我们可以通过 <code>docker run -d redis</code>，指定容器后台运行模式</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run  -d 容器名</span><br></pre></td></tr></table></figure>

<p>注意理解 -it 和 -d组参数的区别</p>
<p><code>docker run -it ubuntu</code>：启动一个 ubuntu 容器实例，并且返回一个交互式窗口</p>
<p><code>docker run -d ubuntu</code>：后台启动一个 ubuntu 容器实例，注意，这时并没有返回一个前台的交互式窗口，所以启动的 ubuntu 容器实例会被立刻杀死（后台启动，并且没有前台交互式窗口连接，默认认为没用，所以实例被杀死），具体见下面实例：</p>
<p><strong>示例一：以 ubuntu 演示</strong></p>
<p><img src="/oct25-xxxxx/img/docker/docker08.png" alt="使用-d参数运行ubuntu"></p>
<p>注意：Docker 容器后台运行，就必须有一个前台进程（<strong>不是所有，只是部分容器&#x2F;镜像是这样</strong>）；容器运行的命令如果不是那些一直挂起的命令，就会自己自动退出</p>
<p><strong>示例二：以 Redis 演示</strong></p>
<ol>
<li>使用 -it 启动一个 redis</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -it redis:7.0.11</span><br></pre></td></tr></table></figure>

<p><img src="/oct25-xxxxx/img/docker/docker09.png" alt="使用-it参数运行redis"></p>
<p><code>启动一个交互式容器，注意，此时 redis 占用前台会话窗口，当 Ctrl + C 时，容器就会被杀死</code></p>
<ol start="2">
<li>我们在使用 redis 时，通常是将 redis 后台启动作为一个后台进程（或守护进程）即可，不需要占用前台会话窗口</li>
</ol>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker run -d redis:7.0.11</span><br></pre></td></tr></table></figure>

<p><img src="/oct25-xxxxx/img/docker/docker10.png" alt="使用-d参数运行redis"></p>
<p><code>启动一个后台守护进程，redis 进程后台运行，不会占用当前会话窗口</code></p>
<h3 id="查看容器日志"><a href="#查看容器日志" class="headerlink" title="查看容器日志"></a><code>查看容器日志</code></h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker logs 容器<span class="built_in">id</span>或容器名</span><br></pre></td></tr></table></figure>

<p><strong>示例：查看 redis 日志</strong></p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop200 ~]$ docker ps</span><br><span class="line">CONTAINER ID   IMAGE         COMMAND                  CREATED         STATUS         PORTS      NAMES</span><br><span class="line">5eaafab2602c   redis:6.0.8   <span class="string">&quot;docker-entrypoint.s…&quot;</span>   4 minutes ago   Up 4 minutes   6379/tcp   strange_meninsky</span><br><span class="line">[root@hadoop200 ~]$ </span><br><span class="line">[root@hadoop200 ~]$ </span><br><span class="line">[root@hadoop200 ~]$ </span><br><span class="line">[root@hadoop200 ~]$ docker logs 5eaafab2602c</span><br><span class="line">1:C 26 Apr 2023 23:51:19.879 <span class="comment"># oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo</span></span><br><span class="line">1:C 26 Apr 2023 23:51:19.879 <span class="comment"># Redis version=7.0.11, bits=64, commit=00000000, modified=0, pid=1, just started</span></span><br><span class="line">1:C 26 Apr 2023 23:51:19.879 <span class="comment"># Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf</span></span><br><span class="line">1:M 26 Apr 2023 23:51:19.880 * monotonic clock: POSIX clock_gettime</span><br><span class="line">1:M 26 Apr 2023 23:51:19.880 * Running mode=standalone, port=6379.</span><br><span class="line">1:M 26 Apr 2023 23:51:19.881 <span class="comment"># WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.</span></span><br><span class="line">1:M 26 Apr 2023 23:51:19.881 <span class="comment"># Server initialized</span></span><br><span class="line">1:M 26 Apr 2023 23:51:19.881 <span class="comment"># WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add &#x27;vm.overcommit_memory = 1&#x27; to /etc/sysctl.conf and then reboot or run the command &#x27;sysctl vm.overcommit_memory=1&#x27; for this to take effect.</span></span><br><span class="line">1:M 26 Apr 2023 23:51:19.882 * Ready to accept connections</span><br></pre></td></tr></table></figure>

<h3 id="查看容器内运行的进程"><a href="#查看容器内运行的进程" class="headerlink" title="查看容器内运行的进程"></a><code>查看容器内运行的进程</code></h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker top 容器<span class="built_in">id</span>或容器名</span><br></pre></td></tr></table></figure>

<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop200 ~]$ docker ps</span><br><span class="line">CONTAINER ID   IMAGE         COMMAND                  CREATED         STATUS         PORTS      NAMES</span><br><span class="line">5eaafab2602c   redis:6.0.8   <span class="string">&quot;docker-entrypoint.s…&quot;</span>   8 minutes ago   Up 8 minutes   6379/tcp   strange_meninsky</span><br><span class="line">[root@hadoop200 ~]$ </span><br><span class="line">[root@hadoop200 ~]$ </span><br><span class="line">[root@hadoop200 ~]$ </span><br><span class="line">[root@hadoop200 ~]$ docker top 5eaafab2602c</span><br><span class="line">\UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD</span><br><span class="line">polkitd             3374                3353                0                   21:38               ?                   00:00:00            redis-server *:6379</span><br><span class="line">[root@hadoop200 ~]$</span><br></pre></td></tr></table></figure>

<h3 id="查看容器内部细节"><a href="#查看容器内部细节" class="headerlink" title="查看容器内部细节"></a><code>查看容器内部细节</code></h3><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker inspect 容器<span class="built_in">id</span>或容器名  </span><br></pre></td></tr></table></figure>

<h3 id="进入正在运行的容器，并以命令行交互"><a href="#进入正在运行的容器，并以命令行交互" class="headerlink" title="进入正在运行的容器，并以命令行交互"></a><code>进入正在运行的容器，并以命令行交互</code></h3><p><strong>进入正在运行的容器，并以命令行交互</strong></p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker <span class="built_in">exec</span> -it 容器<span class="built_in">id</span>或容器名 bashShell</span><br></pre></td></tr></table></figure>

<p><img src="/oct25-xxxxx/img/docker/docker11.png" alt="exec命令演示"></p>
<p>重新进入</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker attach 容器<span class="built_in">id</span>或容器名</span><br></pre></td></tr></table></figure>

<p><img src="/oct25-xxxxx/img/docker/docker12.png" alt="attach命令演示"></p>
<p><strong>exec -it 和 attch 方式区别</strong></p>
<ul>
<li>exec -it，是在容器中打开新的终端，并且可以启动新的进程，然后使用 exit 退出时，不会导致容器停止</li>
<li>attach，直接进入容器启动命令的终端，不会启动新的进程，然后使用 exit 退出时，就会导致容器停止</li>
<li><code>推荐使用 exec -it 方式进入容器，因为在退出时，不会停止容器</code></li>
</ul>
<h3 id="从容器内拷贝文件到主机"><a href="#从容器内拷贝文件到主机" class="headerlink" title="从容器内拷贝文件到主机"></a>从容器内拷贝文件到主机</h3><p>容器 -&gt; 主机</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker <span class="built_in">cp</span> 容器<span class="built_in">id</span>:容器内路径 目的主机路径</span><br></pre></td></tr></table></figure>

<p><img src="/oct25-xxxxx/img/docker/docker13.png" alt="拷贝容器文件到主机"></p>
<h3 id="导入和导出容器"><a href="#导入和导出容器" class="headerlink" title="导入和导出容器"></a><code>导入和导出容器</code></h3><ul>
<li>export 导出容器的内容作为一个 tar 归档文件</li>
</ul>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker <span class="built_in">export</span> 容器<span class="built_in">id</span> &gt; 文件名.tar</span><br></pre></td></tr></table></figure>

<ul>
<li>import 从 tar 包中的内容创建一个新的文件系统，再导入为镜像</li>
</ul>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cat</span> 文件名.tar | docker import - 镜像用户/镜像名:镜像版本号</span><br></pre></td></tr></table></figure>

<p><img src="/oct25-xxxxx/img/docker/docker14.png" alt="导入/导出容器"></p>
<h2 id="四、总结"><a href="#四、总结" class="headerlink" title="四、总结"></a>四、总结</h2><p><img src="/oct25-xxxxx/img/docker/docker15.png"></p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">attach    Attach to a running container                 # 当前 shell 下 attach 连接指定运行镜像</span><br><span class="line">build     Build an image from a Dockerfile              # 通过 Dockerfile 定制镜像</span><br><span class="line">commit    Create a new image from a container changes   # 提交当前容器为新的镜像</span><br><span class="line">cp        Copy files/folders from the containers filesystem to the host path   #从容器中拷贝指定文件或者目录到宿主机中</span><br><span class="line">create    Create a new container                        # 创建一个新的容器，同 run，但不启动容器</span><br><span class="line">diff      Inspect changes on a container&#x27;s filesystem   # 查看 docker 容器变化</span><br><span class="line">events    Get real time events from the server          # 从 docker 服务获取容器实时事件</span><br><span class="line">exec      Run a command in an existing container        # 在已存在的容器上运行命令</span><br><span class="line">export    Stream the contents of a container as a tar archive   # 导出容器的内容流作为一个 tar 归档文件[对应 import ]</span><br><span class="line">history   Show the history of an image                  # 展示一个镜像形成历史</span><br><span class="line">images    List images                                   # 列出系统当前镜像</span><br><span class="line">import    Create a new filesystem image from the contents of a tarball # 从tar包中的内容创建一个新的文件系统映像[对应export]</span><br><span class="line">info      Display system-wide information               # 显示系统相关信息</span><br><span class="line">inspect   Return low-level information on a container   # 查看容器详细信息</span><br><span class="line">kill      Kill a running container                      # kill 指定 docker 容器</span><br><span class="line">load      Load an image from a tar archive              # 从一个 tar 包中加载一个镜像[对应 save]</span><br><span class="line">login     Register or Login to the docker registry server    # 注册或者登陆一个 docker 源服务器</span><br><span class="line">logout    Log out from a Docker registry server          # 从当前 Docker registry 退出</span><br><span class="line">logs      Fetch the logs of a container                 # 输出当前容器日志信息</span><br><span class="line">port      Lookup the public-facing port which is NAT-ed to PRIVATE_PORT    # 查看映射端口对应的容器内部源端口</span><br><span class="line">pause     Pause all processes within a container        # 暂停容器</span><br><span class="line">ps        List containers                               # 列出容器列表</span><br><span class="line">pull      Pull an image or a repository from the docker registry server   # 从docker镜像源服务器拉取指定镜像或者库镜像</span><br><span class="line">push      Push an image or a repository to the docker registry server    # 推送指定镜像或者库镜像至docker源服务器</span><br><span class="line">restart   Restart a running container                   # 重启运行的容器</span><br><span class="line">rm        Remove one or more containers                 # 移除一个或者多个容器</span><br><span class="line">rmi       Remove one or more images       # 移除一个或多个镜像[无容器使用该镜像才可删除，否则需删除相关容器才可继续或 -f 强制删除]</span><br><span class="line">run       Run a command in a new container              # 创建一个新的容器并运行一个命令</span><br><span class="line">save      Save an image to a tar archive                # 保存一个镜像为一个 tar 包[对应 load]</span><br><span class="line">search    Search for an image on the Docker Hub         # 在 docker hub 中搜索镜像</span><br><span class="line">start     Start a stopped containers                    # 启动容器</span><br><span class="line">stop      Stop a running containers                     # 停止容器</span><br><span class="line">tag       Tag an image into a repository                # 给源中镜像打标签</span><br><span class="line">top       Lookup the running processes of a container   # 查看容器中运行的进程信息</span><br><span class="line">unpause   Unpause a paused container                    # 取消暂停容器</span><br><span class="line">version   Show the docker version information           # 查看 docker 版本号</span><br><span class="line">wait      Block until a container stops, then print its exit code   # 截取容器停止时的退出状态值</span><br></pre></td></tr></table></figure>













</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">Oct25-X</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://oct25-x.atomgit.net/oct25-xxxxx/2023/11/03/35%E5%BC%80%E6%BA%90%E5%BA%94%E7%94%A8%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8EDocker_01Docker%E5%85%A5%E9%97%A8/">https://oct25-x.atomgit.net/oct25-xxxxx/2023/11/03/35%E5%BC%80%E6%BA%90%E5%BA%94%E7%94%A8%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8EDocker_01Docker%E5%85%A5%E9%97%A8/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://oct25-x.atomgit.net/oct25-xxxxx" target="_blank">Oct25-X</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/oct25-xxxxx/tags/Docker/">Docker</a></div><div class="post_share"><div class="social-share" data-image="/oct25-xxxxx/img/cover_img/ctt35.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/oct25-xxxxx/2023/11/16/36%E5%BC%80%E6%BA%90%E5%BA%94%E7%94%A8%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8EDocker_02Docker%E9%95%9C%E5%83%8F%E5%92%8C%E5%AE%B9%E5%99%A8%E6%95%B0%E6%8D%AE%E5%8D%B7/"><img class="prev-cover" src="/oct25-xxxxx/img/cover_img/ctt36.png" onerror="onerror=null;src='/oct25-xxxxx/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">开源应用容器引擎 Docker_02Docker镜像和容器数据卷</div></div></a></div><div class="next-post pull-right"><a href="/oct25-xxxxx/2023/10/27/34%E5%BC%82%E6%9E%84%E6%95%B0%E6%8D%AE%E6%BA%90%E5%90%8C%E6%AD%A5%E5%B7%A5%E5%85%B7DataX/"><img class="next-cover" src="/oct25-xxxxx/img/cover_img/ctt34.png" onerror="onerror=null;src='/oct25-xxxxx/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">异构数据源同步工具DataX</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/oct25-xxxxx/2023/11/16/36%E5%BC%80%E6%BA%90%E5%BA%94%E7%94%A8%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8EDocker_02Docker%E9%95%9C%E5%83%8F%E5%92%8C%E5%AE%B9%E5%99%A8%E6%95%B0%E6%8D%AE%E5%8D%B7/" title="开源应用容器引擎 Docker_02Docker镜像和容器数据卷"><img class="cover" src="/oct25-xxxxx/img/cover_img/ctt36.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-11-16</div><div class="title">开源应用容器引擎 Docker_02Docker镜像和容器数据卷</div></div></a></div><div><a href="/oct25-xxxxx/2023/11/22/37%E5%BC%80%E6%BA%90%E5%BA%94%E7%94%A8%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8EDocker_03%E5%B8%B8%E7%94%A8%E7%BB%84%E4%BB%B6Docker%E5%AE%89%E8%A3%85/" title="开源应用容器引擎Docker_03常用组件Docker安装"><img class="cover" src="/oct25-xxxxx/img/cover_img/ctt37.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-11-22</div><div class="title">开源应用容器引擎Docker_03常用组件Docker安装</div></div></a></div><div><a href="/oct25-xxxxx/2023/12/06/38%E5%BC%80%E6%BA%90%E5%BA%94%E7%94%A8%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8EDocker_04Dockerfile/" title="开源应用容器引擎 Docker_04Dockerfile"><img class="cover" src="/oct25-xxxxx/img/cover_img/ctt38.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-12-06</div><div class="title">开源应用容器引擎 Docker_04Dockerfile</div></div></a></div><div><a href="/oct25-xxxxx/2023/12/19/39%E5%BC%80%E6%BA%90%E5%BA%94%E7%94%A8%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8EDocker_05Docker%E7%BD%91%E7%BB%9C/" title="开源应用容器引擎 Docker_05Docker网络和Comprose容器编排"><img class="cover" src="/oct25-xxxxx/img/cover_img/ctt39.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-12-19</div><div class="title">开源应用容器引擎 Docker_05Docker网络和Comprose容器编排</div></div></a></div><div><a href="/oct25-xxxxx/2023/12/26/40%E5%BC%80%E6%BA%90%E5%BA%94%E7%94%A8%E5%AE%B9%E5%99%A8%E5%BC%95%E6%93%8EDocker_06%E8%BD%BB%E9%87%8F%E7%BA%A7%E5%8F%AF%E8%A7%86%E5%8C%96%E5%B7%A5%E5%85%B7Portainer/" title="开源应用容器引擎 Docker_06轻量级可视化工具Portainer"><img class="cover" src="/oct25-xxxxx/img/cover_img/ctt40.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2023-12-26</div><div class="title">开源应用容器引擎 Docker_06轻量级可视化工具Portainer</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/oct25-xxxxx/img/avatar.jpg" onerror="this.onerror=null;this.src='/oct25-xxxxx/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Oct25-X</div><div class="author-info__description"></div></div><div class="card-info-data is-center"><div class="card-info-data-item"><a href="/oct25-xxxxx/archives/"><div class="headline">文章</div><div class="length-num">52</div></a></div><div class="card-info-data-item"><a href="/oct25-xxxxx/tags/"><div class="headline">标签</div><div class="length-num">17</div></a></div><div class="card-info-data-item"><a href="/oct25-xxxxx/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Docker-%E5%9F%BA%E7%A1%80"><span class="toc-number">1.</span> <span class="toc-text">Docker 基础</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E4%BB%80%E4%B9%88%E6%98%AF-Docker"><span class="toc-number">1.1.</span> <span class="toc-text">一、什么是 Docker</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E5%AE%B9%E5%99%A8%E5%92%8C%E8%99%9A%E6%8B%9F%E6%9C%BA%E6%AF%94%E8%BE%83"><span class="toc-number">1.2.</span> <span class="toc-text">二、容器和虚拟机比较</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%99%9A%E6%8B%9F%E6%9C%BA"><span class="toc-number">1.2.1.</span> <span class="toc-text">虚拟机</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%B9%E5%99%A8%E8%99%9A%E6%8B%9F%E5%8C%96%E6%8A%80%E6%9C%AF"><span class="toc-number">1.2.2.</span> <span class="toc-text">容器虚拟化技术</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%89%E3%80%81Docker-%E8%83%BD%E5%B9%B2%E4%BB%80%E4%B9%88"><span class="toc-number">1.3.</span> <span class="toc-text">三、Docker 能干什么</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9B%9B%E3%80%81Docket-%E7%BB%84%E6%88%90"><span class="toc-number">1.4.</span> <span class="toc-text">四、Docket 组成</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%A6%82%E5%BF%B5"><span class="toc-number">1.4.1.</span> <span class="toc-text">概念</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%95%9C%E5%83%8F%EF%BC%88Image%EF%BC%89"><span class="toc-number">1.4.1.1.</span> <span class="toc-text">镜像（Image）</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AE%B9%E5%99%A8%EF%BC%88Container%EF%BC%89"><span class="toc-number">1.4.1.2.</span> <span class="toc-text">容器（Container）</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BB%93%E5%BA%93%EF%BC%88Repository%EF%BC%89"><span class="toc-number">1.4.1.3.</span> <span class="toc-text">仓库（Repository）</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker-%E5%B9%B3%E5%8F%B0%E6%9E%B6%E6%9E%84%E5%9B%BE%E8%A7%A3%EF%BC%88%E5%85%A5%E9%97%A8%EF%BC%89"><span class="toc-number">1.4.2.</span> <span class="toc-text">Docker 平台架构图解（入门）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#Docker-%E5%B7%A5%E4%BD%9C%E5%8E%9F%E7%90%86"><span class="toc-number">1.4.3.</span> <span class="toc-text">Docker 工作原理</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Docker-%E5%AE%89%E8%A3%85"><span class="toc-number">2.</span> <span class="toc-text">Docker 安装</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%80%E3%80%81Docker-%E4%B8%8B%E8%BD%BD"><span class="toc-number">2.1.</span> <span class="toc-text">一、Docker 下载</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%8C%E3%80%81Docker-%E5%AE%89%E8%A3%85"><span class="toc-number">2.2.</span> <span class="toc-text">二、Docker 安装</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%89%E3%80%81hello-world"><span class="toc-number">2.3.</span> <span class="toc-text">三、hello-world</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9B%9B%E3%80%81%E9%98%BF%E9%87%8C%E4%BA%91%E9%95%9C%E5%83%8F%E5%8A%A0%E9%80%9F"><span class="toc-number">2.4.</span> <span class="toc-text">四、阿里云镜像加速</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%B3%A8%E5%86%8C%E9%98%BF%E9%87%8C%E4%BA%91%E8%B4%A6%E6%88%B7"><span class="toc-number">2.4.1.</span> <span class="toc-text">注册阿里云账户</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%8E%B7%E5%BE%97%E5%8A%A0%E9%80%9F%E5%99%A8%E5%9C%B0%E5%9D%80%E8%BF%9E%E6%8E%A5"><span class="toc-number">2.4.2.</span> <span class="toc-text">获得加速器地址连接</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE%E9%95%9C%E5%83%8F%E5%8A%A0%E9%80%9F%E5%99%A8"><span class="toc-number">2.4.3.</span> <span class="toc-text">配置镜像加速器</span></a></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Docker-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4"><span class="toc-number">3.</span> <span class="toc-text">Docker 常用命令</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%80%E3%80%81%E5%B8%AE%E5%8A%A9%E5%90%AF%E5%8A%A8%E7%B1%BB%E5%91%BD%E4%BB%A4"><span class="toc-number">3.1.</span> <span class="toc-text">一、帮助启动类命令</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%90%AF%E5%8A%A8-Docker"><span class="toc-number">3.1.1.</span> <span class="toc-text">启动 Docker</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%81%9C%E6%AD%A2-Docker"><span class="toc-number">3.1.2.</span> <span class="toc-text">停止 Docker</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%87%8D%E5%90%AF-Docker"><span class="toc-number">3.1.3.</span> <span class="toc-text">重启 Docker</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B-Docker-%E7%8A%B6%E6%80%81"><span class="toc-number">3.1.4.</span> <span class="toc-text">查看 Docker 状态</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BC%80%E6%9C%BA%E5%90%AF%E5%8A%A8-Docker"><span class="toc-number">3.1.5.</span> <span class="toc-text">开机启动 Docker</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B-Docker-%E6%A6%82%E8%A6%81%E4%BF%A1%E6%81%AF"><span class="toc-number">3.1.6.</span> <span class="toc-text">查看 Docker 概要信息</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B-Docker-%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3"><span class="toc-number">3.1.7.</span> <span class="toc-text">查看 Docker 帮助文档</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B-Docker-%E5%85%B7%E4%BD%93%E5%91%BD%E4%BB%A4%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3"><span class="toc-number">3.1.8.</span> <span class="toc-text">查看 Docker 具体命令帮助文档</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%8C%E3%80%81%E9%95%9C%E5%83%8F%E5%91%BD%E4%BB%A4"><span class="toc-number">3.2.</span> <span class="toc-text">二、镜像命令</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%97%E5%87%BA%E6%9C%AC%E5%9C%B0%E4%B8%BB%E6%9C%BA%E4%B8%8A%E7%9A%84%E9%95%9C%E5%83%8F"><span class="toc-number">3.2.1.</span> <span class="toc-text">列出本地主机上的镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E8%AF%A2%E9%95%9C%E5%83%8F"><span class="toc-number">3.2.2.</span> <span class="toc-text">查询镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8B%89%E5%8F%96%E9%95%9C%E5%83%8F"><span class="toc-number">3.2.3.</span> <span class="toc-text">拉取镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E9%95%9C%E5%83%8F-x2F-%E5%AE%B9%E5%99%A8-x2F-%E6%95%B0%E6%8D%AE%E5%8D%B7%E6%89%80%E5%8D%A0%E7%A9%BA%E9%97%B4"><span class="toc-number">3.2.4.</span> <span class="toc-text">查看镜像&#x2F;容器&#x2F;数据卷所占空间</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%A0%E9%99%A4%E9%95%9C%E5%83%8F"><span class="toc-number">3.2.5.</span> <span class="toc-text">删除镜像</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%80%9D%E8%80%83%EF%BC%9A%E4%BB%80%E4%B9%88%E6%98%AF%E8%99%9A%E6%82%AC%E9%95%9C%E5%83%8F%EF%BC%9F"><span class="toc-number">3.2.6.</span> <span class="toc-text">思考：什么是虚悬镜像？</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%89%E3%80%81%E5%AE%B9%E5%99%A8%E5%91%BD%E4%BB%A4"><span class="toc-number">3.3.</span> <span class="toc-text">三、容器命令</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%96%B0%E5%BB%BA%EF%BC%8C%E5%B9%B6%E5%90%AF%E5%8A%A8%E5%AE%B9%E5%99%A8"><span class="toc-number">3.3.1.</span> <span class="toc-text">新建，并启动容器</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#OPTIONS-%E8%AF%B4%E6%98%8E"><span class="toc-number">3.3.1.1.</span> <span class="toc-text">OPTIONS 说明</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%90%AF%E5%8A%A8%E4%BA%A4%E4%BA%92%E5%BC%8F%E5%AE%B9%E5%99%A8%EF%BC%88%E5%89%8D%E5%8F%B0%E5%91%BD%E4%BB%A4%E8%A1%8C%EF%BC%89"><span class="toc-number">3.3.1.2.</span> <span class="toc-text">启动交互式容器（前台命令行）</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%97%E5%87%BA%E5%BD%93%E5%89%8D%E6%89%80%E6%9C%89%E6%AD%A3%E5%9C%A8%E8%BF%90%E8%A1%8C%E7%9A%84%E5%AE%B9%E5%99%A8"><span class="toc-number">3.3.2.</span> <span class="toc-text">列出当前所有正在运行的容器</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#OPTIONs-%E8%AF%B4%E6%98%8E"><span class="toc-number">3.3.2.1.</span> <span class="toc-text">OPTIONs 说明</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%80%E5%87%BA%E5%AE%B9%E5%99%A8"><span class="toc-number">3.3.3.</span> <span class="toc-text">退出容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%90%AF%E5%8A%A8%E5%B7%B2%E5%81%9C%E6%AD%A2%E8%BF%90%E8%A1%8C%E7%9A%84%E5%AE%B9%E5%99%A8"><span class="toc-number">3.3.4.</span> <span class="toc-text">启动已停止运行的容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%87%8D%E5%90%AF%E5%AE%B9%E5%99%A8"><span class="toc-number">3.3.5.</span> <span class="toc-text">重启容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%81%9C%E6%AD%A2%E5%AE%B9%E5%99%A8"><span class="toc-number">3.3.6.</span> <span class="toc-text">停止容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BC%BA%E5%88%B6%E5%81%9C%E6%AD%A2%E5%AE%B9%E5%99%A8"><span class="toc-number">3.3.7.</span> <span class="toc-text">强制停止容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%A0%E9%99%A4%E5%B7%B2%E5%81%9C%E6%AD%A2%E7%9A%84%E5%AE%B9%E5%99%A8"><span class="toc-number">3.3.8.</span> <span class="toc-text">删除已停止的容器</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%90%AF%E5%8A%A8%E5%AE%88%E6%8A%A4%E5%BC%8F%E5%AE%B9%E5%99%A8%EF%BC%88%E5%90%8E%E5%8F%B0%E6%9C%8D%E5%8A%A1%EF%BC%89"><span class="toc-number">3.3.9.</span> <span class="toc-text">启动守护式容器（后台服务）</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E5%AE%B9%E5%99%A8%E6%97%A5%E5%BF%97"><span class="toc-number">3.3.10.</span> <span class="toc-text">查看容器日志</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E5%AE%B9%E5%99%A8%E5%86%85%E8%BF%90%E8%A1%8C%E7%9A%84%E8%BF%9B%E7%A8%8B"><span class="toc-number">3.3.11.</span> <span class="toc-text">查看容器内运行的进程</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E5%AE%B9%E5%99%A8%E5%86%85%E9%83%A8%E7%BB%86%E8%8A%82"><span class="toc-number">3.3.12.</span> <span class="toc-text">查看容器内部细节</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BF%9B%E5%85%A5%E6%AD%A3%E5%9C%A8%E8%BF%90%E8%A1%8C%E7%9A%84%E5%AE%B9%E5%99%A8%EF%BC%8C%E5%B9%B6%E4%BB%A5%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%BA%A4%E4%BA%92"><span class="toc-number">3.3.13.</span> <span class="toc-text">进入正在运行的容器，并以命令行交互</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BB%8E%E5%AE%B9%E5%99%A8%E5%86%85%E6%8B%B7%E8%B4%9D%E6%96%87%E4%BB%B6%E5%88%B0%E4%B8%BB%E6%9C%BA"><span class="toc-number">3.3.14.</span> <span class="toc-text">从容器内拷贝文件到主机</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AF%BC%E5%85%A5%E5%92%8C%E5%AF%BC%E5%87%BA%E5%AE%B9%E5%99%A8"><span class="toc-number">3.3.15.</span> <span class="toc-text">导入和导出容器</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9B%9B%E3%80%81%E6%80%BB%E7%BB%93"><span class="toc-number">3.4.</span> <span class="toc-text">四、总结</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/oct25-xxxxx/2024/02/24/52%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%A4%9A%E8%8C%83%E5%BC%8F%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80Scala09_%E9%9A%90%E5%BC%8F%E8%BD%AC%E6%8D%A2%E3%80%81%E5%BC%82%E5%B8%B8%E5%92%8C%E6%B3%9B%E5%9E%8B/" title="大数据之多范式编程语言 Scala09_隐式转换、异常和泛型"><img src="/oct25-xxxxx/img/cover_img/ctt52.png" onerror="this.onerror=null;this.src='/oct25-xxxxx/img/404.jpg'" alt="大数据之多范式编程语言 Scala09_隐式转换、异常和泛型"/></a><div class="content"><a class="title" href="/oct25-xxxxx/2024/02/24/52%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%A4%9A%E8%8C%83%E5%BC%8F%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80Scala09_%E9%9A%90%E5%BC%8F%E8%BD%AC%E6%8D%A2%E3%80%81%E5%BC%82%E5%B8%B8%E5%92%8C%E6%B3%9B%E5%9E%8B/" title="大数据之多范式编程语言 Scala09_隐式转换、异常和泛型">大数据之多范式编程语言 Scala09_隐式转换、异常和泛型</a><time datetime="2024-02-24T04:55:34.000Z" title="发表于 2024-02-24 12:55:34">2024-02-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/oct25-xxxxx/2024/02/24/51%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%A4%9A%E8%8C%83%E5%BC%8F%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80Scala08_%E6%A8%A1%E5%BC%8F%E5%8C%B9%E9%85%8D/" title="大数据之多范式编程语言 Scala08_模式匹配"><img src="/oct25-xxxxx/img/cover_img/ctt51.png" onerror="this.onerror=null;this.src='/oct25-xxxxx/img/404.jpg'" alt="大数据之多范式编程语言 Scala08_模式匹配"/></a><div class="content"><a class="title" href="/oct25-xxxxx/2024/02/24/51%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%A4%9A%E8%8C%83%E5%BC%8F%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80Scala08_%E6%A8%A1%E5%BC%8F%E5%8C%B9%E9%85%8D/" title="大数据之多范式编程语言 Scala08_模式匹配">大数据之多范式编程语言 Scala08_模式匹配</a><time datetime="2024-02-24T00:46:12.000Z" title="发表于 2024-02-24 08:46:12">2024-02-24</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/oct25-xxxxx/2024/02/22/50%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%A4%9A%E8%8C%83%E5%BC%8F%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80Scala07_%E9%9B%86%E5%90%88/" title="大数据之多范式编程语言 Scala07_集合"><img src="/oct25-xxxxx/img/cover_img/ctt50.png" onerror="this.onerror=null;this.src='/oct25-xxxxx/img/404.jpg'" alt="大数据之多范式编程语言 Scala07_集合"/></a><div class="content"><a class="title" href="/oct25-xxxxx/2024/02/22/50%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%A4%9A%E8%8C%83%E5%BC%8F%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80Scala07_%E9%9B%86%E5%90%88/" title="大数据之多范式编程语言 Scala07_集合">大数据之多范式编程语言 Scala07_集合</a><time datetime="2024-02-22T08:16:10.000Z" title="发表于 2024-02-22 16:16:10">2024-02-22</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/oct25-xxxxx/2024/02/21/49%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%A4%9A%E8%8C%83%E5%BC%8F%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80Scala06_%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/" title="大数据之多范式编程语言 Scala06_面向对象"><img src="/oct25-xxxxx/img/cover_img/ctt49.png" onerror="this.onerror=null;this.src='/oct25-xxxxx/img/404.jpg'" alt="大数据之多范式编程语言 Scala06_面向对象"/></a><div class="content"><a class="title" href="/oct25-xxxxx/2024/02/21/49%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%A4%9A%E8%8C%83%E5%BC%8F%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80Scala06_%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/" title="大数据之多范式编程语言 Scala06_面向对象">大数据之多范式编程语言 Scala06_面向对象</a><time datetime="2024-02-21T07:01:10.000Z" title="发表于 2024-02-21 15:01:10">2024-02-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/oct25-xxxxx/2024/02/20/48%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%A4%9A%E8%8C%83%E5%BC%8F%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80Scala05_%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BC%96%E7%A8%8B/" title="大数据之多范式编程语言 Scala05_函数式编程"><img src="/oct25-xxxxx/img/cover_img/ctt48.png" onerror="this.onerror=null;this.src='/oct25-xxxxx/img/404.jpg'" alt="大数据之多范式编程语言 Scala05_函数式编程"/></a><div class="content"><a class="title" href="/oct25-xxxxx/2024/02/20/48%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B9%8B%E5%A4%9A%E8%8C%83%E5%BC%8F%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80Scala05_%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BC%96%E7%A8%8B/" title="大数据之多范式编程语言 Scala05_函数式编程">大数据之多范式编程语言 Scala05_函数式编程</a><time datetime="2024-02-20T12:05:11.000Z" title="发表于 2024-02-20 20:05:11">2024-02-20</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('/oct25-xxxxx/img/top_img/top_bg9.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2024 By Oct25-X</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">本地搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div id="rightMenu"><div class="rightMenu-group rightMenu-small"><div class="rightMenu-item" id="menu-backward"><i class="fa-solid fa-arrow-left"></i></div><div class="rightMenu-item" id="menu-forward"><i class="fa-solid fa-arrow-right"></i></div><div class="rightMenu-item" id="menu-refresh"><i class="fa-solid fa-arrow-rotate-right"></i></div><div class="rightMenu-item" id="menu-home"><i class="fa-solid fa-house"></i></div></div><div class="rightMenu-group rightMenu-line rightMenuOther"><a class="rightMenu-item menu-link" href="/archives/"><i class="fa-solid fa-archive"></i><span>文章归档</span></a><a class="rightMenu-item menu-link" href="/categories/"><i class="fa-solid fa-folder-open"></i><span>文章分类</span></a><a class="rightMenu-item menu-link" href="/tags/"><i class="fa-solid fa-tags"></i><span>文章标签</span></a></div><div class="rightMenu-group rightMenu-line rightMenuNormal"><a class="rightMenu-item" id="menu-translate"><i class="fa-solid fa-earth-asia"></i><span>繁简切换</span></a><div class="rightMenu-item" id="menu-darkmode"><i class="fa-solid fa-moon"></i><span>切换模式</span></div></div></div><div id="rightmenu-mask"></div><div><script src="/oct25-xxxxx/js/utils.js"></script><script src="/oct25-xxxxx/js/main.js"></script><script src="/oct25-xxxxx/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script><script src="/oct25-xxxxx/js/search/local-search.js"></script><div class="js-pjax"></div><script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script><script defer data-pjax src="/js/rightMenu.js"></script><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="false" data-click="true"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="false"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>